﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Daphne.Forms
{
    /// <summary>
    /// Interaction logic for Licenses.xaml
    /// </summary>
    public partial class Licenses : Window
    {
        private LicensesParser _parser;

        public Licenses()
        {
            InitializeComponent();
            btnClose.Click += btnClose_Click;
        }

        void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public void Load(string sAppPath)
        {
            _parser = new LicensesParser(sAppPath);
            _parser.Parse();

            uxProgramName.Text = _parser.ProgramName;
            uxURL.Text = _parser.ProgramURL;
            uxLink.NavigateUri = new Uri(_parser.ProgramURL);
            this.DataContext = _parser.LibraryRecords;
        }

        private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
            e.Handled = true;
        }
    }
}
